package com.topisv.tms.api;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.topisv.tms.utils.JsonUtil;
import com.topisv.tms.utils.SystemUtil;
import com.topisv.tms.web.base.BaseController;

/**
 * wms外部系统API_test
 * 
 */
@Controller
@RequestMapping(value = "/api_test")
public class WMSAPIController_Test extends BaseController{

	/**
	 * 创建入库单接口_test
	 * @param appkey  密钥
	 * @param appsecret 公钥
	 * @param data 入库单信息数据（json格式）
	 * @param request
	 * @param response
	 */
	@RequestMapping(value = "createInstorageBill_test")
	public void createInstorageBill_test(HttpServletRequest request, HttpServletResponse response) {

		String appkey="chenhong";
		
		Map<String, String> dataMap=new HashMap<String, String>();
		dataMap.put("customerCode", "RY1");
		dataMap.put("warehouseCode", "HN");
		dataMap.put("boxNum", "1");
		dataMap.put("skuNum", "2");
		dataMap.put("goodsNum", "3");
		dataMap.put("aboutCode", "123456789");
		dataMap.put("remarks", "test...");
		String dataJson = JsonUtil.getObjectString(dataMap);
		
		String md5 = SystemUtil.MD5(dataJson + appkey);
		String appsecret = SystemUtil.getBASE64(md5);
		
		StringBuffer sHtmlText = new StringBuffer();
		sHtmlText.append("<form id='pyForm' name='pyForm' action='http://localhost:8080/wms/api/createInstorageBill' method='post'>");
		sHtmlText.append("<input type='hidden' name='appkey' value='"+appkey+"'/>");
		sHtmlText.append("<input type='hidden' name='appsecret' value='"+appsecret+"'/>");
		sHtmlText.append("<input type='hidden' name='data' value='"+dataJson+"'/>");
		sHtmlText.append("<input type='submit' value='submit' style='display:none;'></form>");
		sHtmlText.append("<script>document.forms['pyForm'].submit();</script>");
		String fromurl = sHtmlText.toString();
		
		log.info(fromurl);
		
	}
	
	
	/**
	 * 创建商品信息接口_test
	 * @param appkey  密钥
	 * @param appsecret 公钥
	 * @param data 入库单信息数据（json格式）
	 * @param request
	 * @param response
	 */
	@RequestMapping(value = "createGoodsInfo_test")
	public void createGoodsInfo_test(HttpServletRequest request, HttpServletResponse response) {

		String appkey="chenhong";
		
		Map<String, String> dataMap=new HashMap<String, String>();
		dataMap.put("customerCode", "");
		dataMap.put("sku", "sku_aaaa");
		dataMap.put("barCode", "barCode_aaa");
		dataMap.put("barName", "barName_aaa");
		dataMap.put("goodsName", "goodsName_aaa");
		dataMap.put("GW", "10");
		dataMap.put("NW", "20");
		dataMap.put("length", "1");
		dataMap.put("width", "2");
		dataMap.put("height", "3");
		dataMap.put("color", "red");
		dataMap.put("size", "50");
		String dataJson = JsonUtil.getObjectString(dataMap);
		
		String md5 = SystemUtil.MD5(dataJson + appkey);
		String appsecret = SystemUtil.getBASE64(md5);
		
		StringBuffer sHtmlText = new StringBuffer();
		sHtmlText.append("<form id='pyForm' name='pyForm' action='http://localhost:8080/wms/api/createGoodsInfo' method='post'>");
		sHtmlText.append("<input type='hidden' name='appkey' value='"+appkey+"'/>");
		sHtmlText.append("<input type='hidden' name='appsecret' value='"+appsecret+"'/>");
		sHtmlText.append("<input type='hidden' name='data' value='"+dataJson+"'/>");
		sHtmlText.append("<input type='submit' value='submit' style='display:none;'></form>");
		sHtmlText.append("<script>document.forms['pyForm'].submit();</script>");
		String fromurl = sHtmlText.toString();
		
		log.info(fromurl);
		
	}
		

}
